package ssh

import "fmt"

type SSHResult struct {
    Code   int
    StdOut string
    StdErr string
}

func (result SSHResult) ToString() string {
    if result.Code == 0 {
        return fmt.Sprintf("{ Code : %d , StdOut : %s }", result.Code, result.StdOut)
    }
    return fmt.Sprintf("{ Code : %d , StdOut : %s , StdErr : %s }", result.Code, result.StdOut, result.StdErr)
}

func (result SSHResult) GetErr() string {
    if result.StdOut == "" || result.StdErr == "" {
        if result.StdErr == "" {
            return result.StdOut
        } else {
            return result.StdErr
        }
    } else if result.StdOut == "" && result.StdErr == "" {
        return fmt.Sprintf("Out : %s , Err : %s", result.StdOut, result.StdErr)
    } else {
        return result.ToString()
    }
}
